#include<iostream>
#include<unistd.h>
using namespace std;
int main()
{ 
  /*pid_t id = getpid();
  for(int i = 1;;i++)
  {
    cout<<"id->"<<id<<"  ";
    cout<<i<<endl;
    sleep(1);
  }*/

  pid_t id = fork();
  if(id == 0)
  {
    while(true)
    {
      pid_t pid = getpid();
      cout<<"这是子进程"<<"->"<<pid<<endl;
      sleep(1);
    }
  }
  else if(id > 0)
  {
    while(true)
    {
      pid_t pid = getpid();
      cout<<"这是父进程"<<"->"<<pid<<endl;
      sleep(1);
    }
  }
  return 0;
}
